package com.lefull.lefullbase.customView.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;

/**
 * Created by Jack on 2016/9/22.
 */
public class LefullScrollView extends ScrollView {
    private OnScrollMoveListener onScrollChangeListener;
    private int bannerHeight;

    public void setOnScrollMoveListener(OnScrollMoveListener onScrollChangeListener) {
        this.onScrollChangeListener = onScrollChangeListener;
    }

    public LefullScrollView(Context context) {
        super(context);
    }

    public LefullScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LefullScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (onScrollChangeListener != null && y != bannerHeight) {
//            L.debug("onScrollChanged", "x " + x + " y " + y + " oldx " + oldx + " oldy " + oldy);
            onScrollChangeListener.onScroll(this, x, y, oldx, oldy);
        }
    }

    public void setBannerHeight(int height) {
        this.bannerHeight = height;
    }

    public interface OnScrollMoveListener {
        void onScroll(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY);
    }
}
